# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=whoosh
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=2.7.4
pkgrel=5
pkgdesc="Fast, pure-Python full text indexing, search, and spell checking library (mingw-w64)"
url='https://github.com/mchaput/whoosh'
license=('BSD')
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clangarm64' 'clang32')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools"
             'git')
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest-runner")
source=("git+https://github.com/mchaput/whoosh#tag=v${pkgver}")
sha256sums=('SKIP')

prepare() {
  cd ${srcdir}
  cp -r ${_realname} build-python-${CARCH}
}

build() {
  cd "${srcdir}/build-python-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

check() {
  cd "${srcdir}/build-python-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py ptr || echo "Tests failed"
}

package() {
  cd "${srcdir}/build-python-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" --skip-build

  install -D -m644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}"/share/licenses/python-${_realname}/LICENSE.txt
}
